package com.guldan.core.utils;

/**
 * Created by Silas.
 * Date: 2016/10/1
 * Time: 22:22
 */
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;

public final class RequestUtil {
    private RequestUtil() {
    }

    public static String getNginxRealIp(HttpServletRequest request) {
        if(request == null) {
            return null;
        } else {
            String ip = request.getHeader("X-Real-IP");
            if(StringUtils.isBlank(ip)) {
                ip = request.getRemoteAddr();
            }

            return ip;
        }
    }
}

